<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/lib/layui/css/layui.css"
          media="all">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/css/public.css" media="all">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static/css/wp.css" media="all">

    <style>
        .item {
            height: 50px;
            border-bottom: 1px solid #dddddd;
            line-height: 50px;
        }

        .key {
            float: left;
        }

        .value {
            float: right;
        }

        .input-block {
            margin-right: 50px;
        }

        .unit {
            position: absolute;
            right: 0px;
            top: 0px;
            right: -30px;
            line-height: 40px;
        }
    </style>
</head>
<body>
<div id="container" class="layuimini-container">
    <div class="layuimini-main">

        <h2 class="wp-module-title">提币申请</h2>
        <div class="wp-module-box wp-module-border">

            <div class="item">
                <div class="key">申请账户</div>
                <div class="value" v-text="accountId">0xerudjcmsldeqplmkdjwuxxqkdmryeuec</div>
            </div>

            <div class="item">
                <div class="key">提币金额</div>
                <div class="value"><span v-text="mentionAmount">200</span>&nbsp;<span v-text="moneyTypeCode">SHQC</span></div>
            </div>

            <div class="item">
                <div class="key">提币地址</div>
                <div class="value" v-text="walletAddress">27jsdkrpllmcqfjhdjnv</div>
            </div>

            <div class="item">
                <div class="key">申请时间</div>
                <div class="value" v-text="createDate">2020.01.11</div>
            </div>

            <div class="item">
                <div class="key">手续费</div>
                <div class="value"><span v-text="serviceCharge">200</span>&nbsp;<span v-text="moneyTypeCode">SHQC</span></div>
            </div>

            <div class="item">
                <div class="key">备注</div>
                <div class="value" v-text="remark">无</div>
            </div>

        </div>

        <div class="wp-module-box" style="margin-top: 15px">
            <h3><b>处理信息</b></h3>
            <form id="myform" class="layui-form" lay-filter="example" style="padding-top: 10px;margin-left:-35px;">
                <div class="layui-form-item">
                    <label class="layui-form-label">处理结果</label>
                    <div class="layui-input-block">
                        <select v-model="operResult" lay-filter="operResult">
                            <option value="1000" selected="">同意</option>
                            <option value="2000">拒绝</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">处理原因</label>
                    <div class="layui-input-block">
                        <textarea v-model="operRemark" class="layui-textarea" lay-verify="emptyCheck"></textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block" style="margin: auto;text-align: center;">
                        <button type="submit" style="width: 120px;" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="data-submit-btn">
                            提交
                        </button>
                    </div>
                </div>
            </form>
        </div>

    </div>
</div>

<script src="/wpui-admin/wp-ewallet-admin/static/js/jquery-3.4.1.min.js"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/lib/layui/layui.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/module/index/config.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/js/vue.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/js/vue-i18n.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp-i18n.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp-project.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            element = layui.element;

        var vm = new Vue({
            el: '#container',
            i18n: wp.i18n(),
            data: {
                reqOrderId:"",
                mentionAmount:"",
                walletAddress:"",
                serviceCharge:"",
                total:"",
                reqType:"",
                orderStatus:"",
                accountId:"",
                reqTypeName:"",
                remark:'',
                createDate:'',
                moneyTypeId:'',
                moneyTypeCode:'',

                // 处理结果
                operResult:'',
                operRemark:'',
                confirmTips:''
            },
            mounted: function () {
                form.render();
                this.selectDoResultEvent();
                this.submitEvent();
                this.getApplyOrder();
            },
            methods: {
                selectDoResultEvent:function(val){
                    var that = this;
                    form.on('select(operResult)', function(data){
                        that.operResult = data.value;
                    });
                },
                getApplyOrder:function(){
                    var that = this;
                    wp.httpGet({
                        url: wp.url("/wp/ewallet/wallet/reqOrder/id/mentionMoney"),
                        data: {
                            orderId: window.data.reqOrderId
                        },
                        success: function (data) {
                            console.log(JSON.stringify(data.dataBody));
                            $.extend(that,data.dataBody);
                            that.operResult = '1000';
                            that.$nextTick(function(){
                                form.render();
                            });
                        }
                    })
                },
                submitEvent: function () {
                    var that = this;
                    // 需要的时候自定义验证规则
                    form.verify({
                        emptyCheck:function(value){
                            if(!value){
                                return '不能为空';
                            }
                        }
                    });
                    // 监听提交操作
                    form.on('submit(data-submit-btn)', function (data) {
                        if(that.operResult == '2000'){
                            that.confirmTips = '确认拒绝提币申请?';
                        }
                        if(that.operResult == '1000'){
                            that.confirmTips = '确认同意提币申请?';
                        }
                        layer.confirm(that.confirmTips, {title:"提示信息",icon:0}, function(index) {
                            layer.close(index);
                            var loading = wp.loading();
                            wp.httpPost({
                                url: wp.url('/wp/ewallet/wallet/mentionMoney/handerMentionMoneyOrder'),
                                data: {
                                    reqOrderId: that.reqOrderId,
                                    operRemark: that.operRemark,
                                    operResult: that.operResult
                                },
                                success: function (data) {
                                    wp.closeLoading();
                                    that.operRemark = '';
                                    layer.msg('处理完成');

                                    // 关闭窗口，刷新父窗口列表
                                    window.walletApplyVm.reloadGrid();
                                    window.close();
                                },
                                failure: function (data) {
                                    wp.closeLoading();
                                    if (data.code == '1') {
                                        layer.msg('订单不存在或者订单状态不是待处理');
                                        return;
                                    }
                                }
                            });
                        });
                        return false;
                    });
                }
            }

        });

    });
</script>

</body>
</html>